/*
 * ListExpressionAst.h
 *
 *  Created on: 8 Nov 2010
 *      Author: kn308
 */

#ifndef LISTEXPRESSIONAST_H_
#define LISTEXPRESSIONAST_H_

#include <vector>
#include "ExpressionAst.h"

namespace MAlice
{

class ListAst: public MAlice::ExpressionAst
{
private:
	vector<Ast*> mChildren;
public:
	ListAst(Ast* child) :
		mChildren(1, child)
	{
	}

	ListAst(const vector<Ast*>& children) :
		mChildren(children)
	{
	}

	virtual ~ListAst() {}

	virtual llvm::Value* generate()
	{
		std::vector<Ast*>::iterator i = mChildren.begin();
		std::vector<Ast*>::iterator e = mChildren.end();
		Value* value = NULL;
		for (; i != e; i++)
			value = (*i)->generate();
		return value;
	}

	ListAst* adopt(Ast* child)
	{
		mChildren.push_back(child);
		return this;
	}
};


}

#endif /* ListAst_H_ */
